fin2022=open("D:\\2022.csv","r")

map2022={}

for line in fin2022:
    line=line.strip()
    t=line.split(',')
    if t[0] in map2022:
        map2022[t[0]]+=float(t[1])
    else:
        map2022[t[0]]=float(t[1])
    
fout2022=open("D:\\2022_out.csv","w")
for key in map2022:
    line=str(key)+","+str(map2022[key])+"\n"
    fout2022.write(line)
fout2022.close()

fin2023=open("D:\\2023.csv","r")

map2023={}

for line in fin2023:
    line=line.strip()
    t=line.split(',')
    if t[0] in map2023:
        map2023[t[0]]+=float(t[1])
    else:
        map2023[t[0]]=float(t[1])
    
fout2023=open("D:\\2023_out.csv","w")
for  key in map2023:
    line=str(key)+","+str(map2023[key])+"\n"
    fout2023.write(line)
fout2023.close()